package com.String;

import java.util.Scanner;

/*
找出小字符串在大字符串出现的次数
*/
public class Demo07 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个大的字符串：");
        String bigstr = sc.next();
        System.out.println("请输入一个小的字符串：");
        String smallstr = sc.next();
        int count = 0;
        while (true) {
            int index = bigstr.indexOf(smallstr);
            if (index == -1) {
                break;
            }
            count++;
            bigstr = bigstr.substring(index + smallstr.length());
        }
        System.out.println("小字符串在大字符串出现" + count + "次！");
    }
}
